<?php
##############################################
#
#   详情页
# @ Time : 2017-3-1 - 下午11:55:14
# @ Author : JiangYongWei <1085562810@qq.com>
# @ Encoding : UTF-8 language : PHP
#
##############################################

namespace Home\Controller;
use Think\Controller;
use Home\Model\GoodsModel;
use Home\Model\CategoryModel;

class DetailController extends Controller{
	private $gid;
	
	public function _initialize(){
		$this -> gid = intval(I('get.gid'));
		$this -> assign('username', $_SESSION['username']);
		$this -> setNav();
	}
	
	protected function setNav(){
		$category_model = new CategoryModel();
		$nav = $category_model -> getCategoryLevel(0);
		$this -> assign('nav', $nav);
	}
	
	//商品详情页
	public function index(){
		$goods_model = new GoodsModel();
		$goods_detail = $goods_model -> getGoodsDetail($this -> gid);
		$temArr = array();
		foreach ($goods_detail as $k => $v){
			$temArr = $v;
		}
		$this -> assign('detail', $temArr);
		$this -> display('index');
	}
}